package ${package.Controller};

import ${package.Service}.${table.serviceName};
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.goodcol.muses.servicebase.annotation.Permission;
import com.goodcol.muses.servicebase.consts.Consts;
import ${package.Other}.${entity}AddDTO;
import ${package.Other}.${entity}UpdateDTO;
import ${package.Other}.${entity}QueryDTO;
import ${package.Parent}.vo.${entity}QueryVO;
import ${package.Parent}.vo.${entity}PageVO;
import com.github.pagehelper.PageInfo;
import com.goodcol.muses.servicebase.vo.ResultVO;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import java.util.List;

/**
 * ${table.comment!} Controller接口类
 *
 * @author ${author}
 * @date ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    private final ${table.serviceName} baseService;

    public ${table.controllerName}(${table.serviceName} baseService) {
        this.baseService = baseService;
    }

    /**
    * 新增
    *
    * @param: addDto
    * @return: Object
    * @author ${author}
    * @date ${date}
    */
    @PostMapping("/add")
    @Permission(Consts.PermissionCode.USER)
    public ResultVO<String> add(@Validated @RequestBody ${entity}AddDTO addDto) {
        return baseService.add(addDto);
    }

    /**
    * 删除
    *
    * @param: ids
    * @return: Object
    * @author ${author}
    * @date ${date}
    */
    @PostMapping("/deletes")
    @Permission(Consts.PermissionCode.USER)
    public ResultVO<String> deletes(@RequestBody List<String> ids) {
         return baseService.deletes(ids);
    }

     /**
     * 修改
     *
     * @param: updateDto
     * @return: Object
     * @author ${author}
     * @date ${date}
     */
     @PostMapping("/edit")
     @Permission(Consts.PermissionCode.USER)
     public ResultVO<String> edit(@Validated @RequestBody ${entity}UpdateDTO updateDto) {
         return baseService.edit(updateDto);
     }

     /**
     * 分页查询
     *
     * @param: queryDto
     * @return: Object
     * @author ${author}
     * @date ${date}
     */
     @GetMapping("/queryPage")
     @Permission(Consts.PermissionCode.USER)
     public ResultVO<PageInfo<${entity}PageVO>> page(@Validated ${entity}QueryDTO queryDto) {
         return new ResultVO<>(baseService.page(queryDto));
     }

     /**
     * 详情
     *
     * @param: id
     * @return: Object
     * @author ${author}
     * @date ${date}
     */
     @GetMapping("/detail")
     @Permission(Consts.PermissionCode.USER)
     public ResultVO<${entity}QueryVO> detail(String id) {
         return new ResultVO<>(baseService.detail(id));
     }

}
</#if>
